package controle;

import java.io.ObjectInputStream;
import java.net.Socket;

public class CriaConexaoHandler extends Thread{
	
	private Socket conexao;
	private ControlePortas controlePortas;
	
	public CriaConexaoHandler(Socket socket)
	{
		this.conexao = socket;
	}
	
	public void run()
	{
		try
		{  
			
			ObjectInputStream stream = new ObjectInputStream(conexao.getInputStream());   
			this.controlePortas = (ControlePortas) stream.readObject();
			
			this.controlePortas.setIpFonte(this.conexao.getInetAddress().getHostAddress());
		
			CriaConexaoWorker conexaoWorker = new CriaConexaoWorker(this.controlePortas);
			conexaoWorker.start();
		}
		catch(Exception e){  
			e.printStackTrace();   
		}  
	}
}